<template>
  <div>
    <div class="freeback-container">
      <div class="freeback-img-box">
        <img src="static/img/freeback.png">
      </div>
      <div class="freeback-box-border">
        <div class="freeback-box">
          <div class="freeback-title">
            <h1>意见反馈</h1>
            <h2>感谢你的反馈，我们会积极改善，做出更好的服务的</h2>
          </div>
          <div class="freeback-content">
            <div class="freeback-form">
              <Form :model="formItem" :label-width="80">
                <FormItem label="标题">
                  <i-input v-model="formItem.title" placeholder="请输入标题"></i-input>
                </FormItem>
                <FormItem label="反馈信息">
                  <i-input v-model="formItem.content" type="textarea" :autosize="{minRows: 8,maxRows: 10}" placeholder="请输入反馈信息"></i-input>
                </FormItem>
                <FormItem>
                  <Button type="primary" @click="submit">提交</Button>
                  <Button  @click="clean">清空信息</Button>
                </FormItem>
              </Form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapMutations } from 'vuex';
export default {
  name: 'Freeback',
  data () {
    return {
      formItem: {
        title: '',
        content: ''
      }
    };
  },
  methods: {
    ...mapMutations(['ADD_USERFK']),
    submit () {
      if (this.formItem.title === '') {
        this.$Message.error('请输入标题');
        return;
      }
      if (this.formItem.content === '') {
        this.$Message.error('请输入内容');
        return;
      }
      if (!localStorage.getItem('loginInfo')) {
        this.$Message.error('请先登录');
        return;
      }
      const list = {
        user: localStorage.getItem('loginInfo'),
        title: this.formItem.title,
        content: this.formItem.content,
        createAt: new Date().getTime()

      };
      this.ADD_USERFK(list);
      this.$Message.success({
        content: '提交成功',
        duration: 6,
        closable: true
      });
      this.formItem.title = '';
      this.formItem.content = '';
    },
    clean () {
      this.formItem.title = '';
      this.formItem.content = '';
    }
  }
};
</script>

<style scoped>
.freeback-container {
  margin: 15px auto;
  width: 80%;
  height: 600px;
  display: flex;
  align-items: center;
  /* background-color: #ccc; */
}
.freeback-img-box {
  width: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.freeback-img-box img {
  width: 80%;
}
.freeback-box-border {
  width: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.freeback-box {
  width: 480px;
}
.freeback-content {
  margin: 15px auto;
  border: 1px #ccc dotted;
}
.freeback-form {
  margin: 30px auto;
  width: 90%;
}
</style>
